package com.iss.apartmentmanage.mapper;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.iss.apartmentmanage.entity.Menu;
import io.swagger.models.auth.In;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface MenuMapper extends BaseMapper<Menu> {
    /**
     *查询全部菜单
     * @return
     */
    @Select("select * from menu")
    List<Menu>selectMenu();

    //通过用户ID查询功能菜单
    @Select("SELECT menu.* FROM menu " +
            "INNER JOIN role_menu ON role_menu.menu_id=menu.id " +
            "INNER JOIN role on role.id=role_menu.role_id " +
            "INNER JOIN user_role on user_role.role_id=role.id " +
            "INNER JOIN `user` ON `user`.id=user_role.user_id " +
            "where `user`.u_name=#{uName} ")
    List<Menu> selectMenuByUserId(String uName);

    //通过用户角色id 查询功能菜单

    List<Menu> selectMenuByRoleId(Integer roleId);
}
